package com.sawyer.constant;

import com.alibaba.fastjson.JSON;
import com.sawyer.SpiderHelper;
import com.sawyer.model.bawang.Data;
import com.sawyer.model.bawang.Result;
import com.sawyer.model.bawang.ShopData;
import com.sawyer.model.taning.*;
import com.sawyer.model.tianlala.TianLalaData;
import com.sawyer.model.tianlala.TianLalaResult;
import com.sawyer.model.tianlala.TianLalaShopData;

import java.util.List;
import java.util.Map;

/**
 * @author : SawyerQiu
 * @date : 2024/6/4 10:18
 */
public enum SpiderType {

    BaWangChaji {
        @Override
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(page, cityId);
            System.out.println(String.format("===> 获取霸王茶几数据 %s 城市 %s 页数据", cityId, page));

            String resultString = SpiderHelper.execCmd(crulCmd);

            Result result = JSON.parseObject(resultString, Result.class);

            Data data = result.getData();
            if (data == null) {
                return;
            }

            List<ShopData> shopDataList = data.getData();
            if (shopDataList == null || shopDataList.size() == 0) {
                return;
            }

            for (ShopData shopData : shopDataList) {
                Object managerPhone = shopData.getShopDetail().get("managerPhone");
                if (managerPhone == null) {
                    continue;
                }

                String managerPhoneStr = ((String) managerPhone).trim();
                if (managerPhoneStr.length() == 0) {
                    continue;
                }

                stringBuilder.append(shopData.getShopDetail().get("name")).append(", ").append(managerPhoneStr).append("\n");
            }

            int totalPage = data.getTotalPage();

            if (totalPage > page) {
                startSpider(page + 1, cityId, stringBuilder);
            }
        }


        @Override
        public String getCrulCmd(Object... param) {
            String[] BA_WANG_CHAJI_CMDS = {"curl",
                    "-H", "\"Host: webapi2.qmai.cn\"",
                    "-H", "\"promotion-code: \"",
                    "-H", "\"work-wechat-userid: \"",
                    "-H", "\"store-id: 49006\"",
                    "-H", "\"accept-language: zh-CN\"",
                    "-H", "\"work-staff-id: \"",
                    "-H", "\"scene: 1256\"",
                    "-H", "\"qm-from-type: catering\"",
                    "-H", "\"multi-store-id: \"",
                    "-H", "\"qm-user-token: n_W6oAce1a65SsJ5SGk8AlEftBQF0QhH6AVnFUiUT7_XOPeEd__Avlm9x9PuS0q9\"",
                    "-H", "\"work-staff-name: \"",
                    "-H", "\"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090a13) XWEB/9129\"",
                    "-H", "\"qz-gtd: \"",
                    "-H", "\"qm-from: wechat\"",
                    "-H", "\"content-type: application/json\"",
                    "-H", "\"accept: v=1.0\"",
                    "-H", "\"channelcode: \"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"gdt-vid: \"",
                    "-H", "\"sec-fetch-site: cross-site\"",
                    "-H", "\"sec-fetch-mode: cors\"",
                    "-H", "\"sec-fetch-dest: empty\"",
                    "-H", "\"referer: https://servicewechat.com/wxafec6f8422cb357b/167/page-frame.html\"",
                    "--data-binary", "\"" + getData(param) + "\"", "\"" + SpiderConstant.BA_WANG_CHAJI_URL + "\""};
            return String.join(" ", BA_WANG_CHAJI_CMDS);
        }

        @Override
        protected String getData(Object[] param) {
            return "{\\\"page\\\": " + param[0].toString() + ",\\\"pageSize\\\":10,\\\"longitude\\\":114.342529296875,\\\"latitude\\\":30.499839782714844,\\\"saleType\\\":0,\\\"pageType\\\":0,\\\"isAppletShow\\\":1,\\\"cityId\\\":\\\"" + param[1].toString() + "\\\",\\\"appid\\\":\\\"wxafec6f8422cb357b\\\"}";
        }
    },

    TianLaLa {
        @Override
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(cityId);
            System.out.println(String.format("===> 获取甜拉拉数据 %s 城市数据", cityId));

            String resultString = SpiderHelper.execCmd(crulCmd);

            TianLalaResult tianLalaResult = JSON.parseObject(resultString, TianLalaResult.class);

            TianLalaData data = tianLalaResult.getData();
            if (data == null) {
                return;
            }

            List<TianLalaShopData> shopDataList = data.getList();
            if (shopDataList == null || shopDataList.size() == 0) {
                return;
            }

            for (TianLalaShopData shopData : shopDataList) {
                String storePhone = shopData.getStorePhone();
                if (storePhone == null || storePhone.equals("")) {
                    continue;
                }

                stringBuilder.append(shopData.getStoreAddress()).append(", ").append(storePhone).append("\n");
            }

        }

        @Override
        public String getCrulCmd(Object... param) {
            String[] cmds = {
                    "curl",
                    "-H", "\"Host: tll.tianlala.com\"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"Authorization: \"",
                    "-H", "\"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b19)XWEB/11275\"",
                    "-H", "\"Content-Type: application/json\"",
                    "-H", "\"Accept: */*\"",
                    "-H", "\"Sec-Fetch-Site: cross-site\"",
                    "-H", "\"Sec-Fetch-Mode: cors\"",
                    "-H", "\"Sec-Fetch-Dest: empty\"",
                    "-H", "\"Referer: https://servicewechat.com/wx22e1f742100ea917/44/page-frame.html\"",
                    "-H", "\"Accept-Language: zh-CN,zh;q=0.9\"",
                    "--data-binary", "\"{\\\"latitude\\\":30.506053464105367,\\\"longitude\\\":114.34899013773585,\\\"type\\\":0,\\\"businessChannels\\\":1,\\\"city\\\":\\\"" + param[0].toString() + "\\\"}\"",
                    "--compressed", "\"https://tll.tianlala.com/front/store/storelistByCity\""
            };
            return String.join(" ", cmds);
        }
    },

    TaNing {
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(cityId);
            System.out.println(String.format("===> 获取塔拧数据 %s 城市数据", cityId));

            String resultString = SpiderHelper.execCmd(crulCmd);
            TaNingResult taNingResult = JSON.parseObject(resultString, TaNingResult.class);

            TaNingData data = taNingResult.getData();
            if (data == null) {
                return;
            }

            Map<String, Object> moduleData = data.getModuleData();
            if (moduleData == null || moduleData.size() == 0) {
                return;
            }

            Object shopListObj = moduleData.get("shop-list");
            if (shopListObj == null) {
                return;
            }

            TaNingModuleShopListData taNingModuleShopListData = JSON.parseObject(JSON.toJSONString(shopListObj), TaNingModuleShopListData.class);
            if (taNingModuleShopListData == null) {
                return;
            }

            TaNingShopListData taNingShopListData = taNingModuleShopListData.getData();
            if (taNingShopListData == null) {
                return;
            }

            List<TaNingShopData> shopCardList = taNingShopListData.getShopCardList();
            for (TaNingShopData taNingShopData : shopCardList) {
                String phone = taNingShopData.getPhone();
                if (phone == null || phone.equals("")) {
                    continue;
                }

                stringBuilder.append(taNingShopData.getAddress()).append(" ").append(taNingShopData.getName()).append(", ").append(phone).append("\n");
            }
        }

        @Override
        public String getCrulCmd(Object... param) {
            String[] cmds = {
                    "curl",
                    "-H", "\"Host: rms.meituan.com\"",
                    "-H", "\"X-cacheKey: \"",
                    "-H", "\"poiId: \"",
                    "-H", "\"X-token: \"",
                    "-H", "\"versionCode: 5710500\"",
                    "-H", "\"app-template: 2\"",
                    "-H", "\"X-Platform: 71\"",
                    "-H", "\"app-platform: 1\"",
                    "-H", "\"mtgsig: {\\\"a1\\\":\\\"1.2\\\",\\\"a2\\\":1727167614764,\\\"a3\\\":\\\"1727167106838UUQSKWS60e593ce0a815b08d658526270cd17d61850\\\",\\\"a4\\\":\\\"c5c1b36fed28bc296fb3c1c529bc28ed43fcf7e66a40df0b\\\",\\\"a5\\\":\\\"ScZANBwq/wq0+DuVljiF7eKwSgjUCS7vgWgtn8Zev1wN90H1SCCOAsyYkAxyrp+c/H580luVvklSbIBFsrPO+XkSzMsPIbL1kPzllXDjo5PPb49dQ16at0s28hyMB1y2GN2AoZtf7JjrBPwVjjViX8kh15TsHc1sGMEjmX4h6KHSD/0USLV6m/kpXCgZ+03nrpU7ZGgbhqcmWyjFK0MInwvHzl9inEtHn3T5WcCYsLP=\\\",\\\"a6\\\":\\\"w1.3g3Vs/eGcQHFXfG7HP05V8QVzu3BzoX5Y9Q7S7UzedSRX4f+HnyOFwNFHWqPy7sXtv+4bNw1aiZPoijVQrMfgb7PLSNKz1nIFT+fWTC7nY6+NYMlRhMX2tD81Oeeh2gQjCUNGz+2mdbg2aGmxH0cRhiJCyTzH5NmDKsMv/XZJjKH1kxLYfckBpdG9yXJCgnVZ8SG/9YZ3NSqiJhkzfhPmR5UrJZjyAz2xK9yprZ2ojgCpd+EqN2kOj0W4c3aRawMJ9UR3HLawM9RwI5qeiI2gIUCUUqZvlObfhdMLRKzlYm6RtU9RVCvsHBHS/+MLT4RUpHaB53hY+M8BFFCKreTXy4fh1tCnskFq5zWe26HopapmLF1InlxF33ZsTof7cAGBUFJmvblqmwW8QSu5E6KGHD89xS+RxVqwumOH1RHr+kfmxRTzSAm9rQlc7eDSRLUSGyA8mf9PsUk1I1hxIgGv52QN6zQj+HMWBIehPN8A/YMj/RwWkx9QMFhpTFGiwIyz\\\",\\\"a7\\\":\\\"wx670b8b6d7fa53a5a\\\",\\\"x0\\\":3,\\\"d1\\\":\\\"9272bab6313d51cb24a7137c8a2175d1\\\"}\"",
                    "-H", "\"X-user: 11ST19d2bOly17Oz0k.iIItMW7kRZ1HtkW8XsWW\"",
                    "-H", "\"lxcuid: 192232e8e4fc8-5aba63720a9d5c-0-0-192232e8e4fc8\"",
                    "-H", "\"X-appId: wx670b8b6d7fa53a5a\"",
                    "-H", "\"app-id: wx670b8b6d7fa53a5a\"",
                    "-H", "\"M-APPKEY: wxmp_com.sankuai.rmsmenuorderfe.v2.wxapp\"",
                    "-H", "\"promotion-monitoring: \"",
                    "-H", "\"appCode: 51\"",
                    "-H", "\"x-cardId: \"",
                    "-H", "\"M-TRACEID: 810423922173165303\"",
                    "-H", "\"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b19)XWEB/11275\"",
                    "-H", "\"tenantId: 11546201\"", "-H", "\"X-UnionId: ohnXL6LhgQyF6FNrvnS9fpgcigtk\"",
                    "-H", "\"Content-Type: application/json\"",
                    "-H", "\"X-WxappVersion: 5.71.05\"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"app-container: 1\"",
                    "-H", "\"X-From: \"",
                    "-H", "\"X-OpenId: oo9G26z6cOURTeqXOobOAlmkvSCY\"",
                    "-H", "\"X-cardInfo: \"",
                    "-H", "\"X-UserInfo: %7B%22nickname%22%3A%22%22%2C%22headimgurl%22%3A%22%22%7D\"",
                    "-H", "\"app-version: 5.71.05\"",
                    "-H", "\"Accept: */*\"",
                    "-H", "\"Sec-Fetch-Site: cross-site\"",
                    "-H", "\"Sec-Fetch-Mode: cors\"",
                    "-H", "\"Sec-Fetch-Dest: empty\"",
                    "-H", "\"Referer: https://servicewechat.com/wx670b8b6d7fa53a5a/6/page-frame.html\"",
                    "-H", "\"Accept-Language: zh-CN,zh;q=0.9\"",
                    "--data-binary", "\"{\\\"jumpType\\\":0,\\\"partnerType\\\":0,\\\"conditionType\\\":0,\\\"conditionValue\\\":\\\"\\\",\\\"latitude\\\":30.499839782714844,\\\"longitude\\\":114.342529296875,\\\"tenantId\\\":\\\"11546201\\\",\\\"bizType\\\":\\\"100\\\",\\\"cityId\\\":" + param[0].toString() + "}\"",
                    "--compressed", "\"https://rms.meituan.com/diancan/api/zt/shop/fmp?mtShopId=&yodaReady=wx&csecappid=wx670b8b6d7fa53a5a&csecplatform=3&csecversionname=75.48.000&csecversion=1.4.0"
            };
            return String.join(" ", cmds);
        }
    },

    LinLee {
        @Override
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(page, cityId);
            System.out.println(String.format("===> 获取LinLee数据 %s 城市 %s 页数据", cityId, page));

            String resultString = SpiderHelper.execCmd(crulCmd);

            Result result = JSON.parseObject(resultString, Result.class);

            Data data = result.getData();
            if (data == null) {
                return;
            }

            List<ShopData> shopDataList = data.getData();
            if (shopDataList == null || shopDataList.size() == 0) {
                return;
            }

            for (ShopData shopData : shopDataList) {
                Object contactPhone = shopData.getShopDetail().get("contactPhone");
                if (contactPhone == null) {
                    continue;
                }

                String contactPhoneStr = ((String) contactPhone).trim();
                if (contactPhoneStr.length() == 0) {
                    continue;
                }

                stringBuilder.append(shopData.getShopDetail().get("address"))
                        .append(" ")
                        .append(shopData.getShopDetail().get("name"))
                        .append(", ")
                        .append(contactPhoneStr)
                        .append("\n");
            }

            int totalPage = data.getTotalPage();

            if (totalPage > page) {
                startSpider(page + 1, cityId, stringBuilder);
            }
        }

        @Override
        public String getCrulCmd(Object... param) {
            String[] cmds = {
                    "curl",
                    "-H", "\"Host: webapi.qmai.cn\"",
                    "-H", "\"promotion-code: \"",
                    "-H", "\"work-wechat-userid: \"",
                    "-H", "\"store-id: 212501\"",
                    "-H", "\"accept-language: zh-CN\"",
                    "-H", "\"work-staff-id: \"",
                    "-H", "\"scene: 1007\"",
                    "-H", "\"qm-from-type: catering\"",
                    "-H", "\"multi-store-id: \"",
                    "-H", "\"qm-user-token: 18CkAEire-f33VJYXMuY3CG95NMytM_4_5pIQkqYZINVzEK25gNuVcBFsxBQrQIy\"",
                    "-H", "\"work-staff-name: \"",
                    "-H", "\"user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b19)XWEB/11275\"",
                    "-H", "\"qz-gtd: \"",
                    "-H", "\"qm-from: wechat\"",
                    "-H", "\"content-type: application/json\"",
                    "-H", "\"accept: v=1.0\"",
                    "-H", "\"channelcode: \"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"gdt-vid: \"",
                    "-H", "\"sec-fetch-site: cross-site\"",
                    "-H", "\"sec-fetch-mode: cors\"",
                    "-H", "\"sec-fetch-dest: empty\"",
                    "-H", "\"referer: https://servicewechat.com/wx26c7aaacfa017719/55/page-frame.html\"",
                    "--data-binary", "\"{\\\"page\\\":" + param[0].toString() + ",\\\"pageSize\\\":10,\\\"saleType\\\":0,\\\"pageType\\\":0,\\\"isAppletShow\\\":1,\\\"cityId\\\":" + param[1].toString() + ",\\\"longitude\\\":114.342529296875,\\\"latitude\\\":30.499839782714844,\\\"appid\\\":\\\"wx26c7aaacfa017719\\\"}\"",
                    "--compressed", "https://webapi.qmai.cn/web/catering/shop/catering-shop-list"
            };
            return String.join(" ", cmds);
        }
    },

    NingMeng {
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(cityId);
            System.out.println(String.format("===> 获取数据NingMeng %s 城市数据", cityId));

            String resultString = SpiderHelper.execCmd(crulCmd);
            TaNingResult taNingResult = JSON.parseObject(resultString, TaNingResult.class);

            TaNingData data = taNingResult.getData();
            if (data == null) {
                return;
            }

            Map<String, Object> moduleData = data.getModuleData();
            if (moduleData == null || moduleData.size() == 0) {
                return;
            }

            Object shopListObj = moduleData.get("shop-list");
            if (shopListObj == null) {
                return;
            }

            TaNingModuleShopListData taNingModuleShopListData = JSON.parseObject(JSON.toJSONString(shopListObj), TaNingModuleShopListData.class);
            if (taNingModuleShopListData == null) {
                return;
            }

            TaNingShopListData taNingShopListData = taNingModuleShopListData.getData();
            if (taNingShopListData == null) {
                return;
            }

            List<TaNingShopData> shopCardList = taNingShopListData.getShopCardList();
            for (TaNingShopData taNingShopData : shopCardList) {
                String phone = taNingShopData.getPhone();
                if (phone == null || phone.equals("")) {
                    continue;
                }

                stringBuilder.append(taNingShopData.getAddress()).append(" ").append(taNingShopData.getName()).append(", ").append(phone).append("\n");
            }
        }

        @Override
        public String getCrulCmd(Object... param) {
            String[] cmds = {
                    "curl",
                    "-H", "\"Host: rms.meituan.com\"",
                    "-H", "\"X-cacheKey: \"",
                    "-H", "\"poiId: \"",
                    "-H", "\"X-token: UNI-TOKEN-10159618:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjcyMzk0ODksImp0aSI6IjhhOTYzNjcwYWJmODRlNzM5NDhmNDg1NTcxM2RjYmUwIiwibWVtYmVySWQiOjI5MzQ2Mjk0ODJ9.EJYzXy6CmcvD9C5HmgH-wtpOHtWnIBXe0GDqJ2CLSPg;\"",
                    "-H", "\"versionCode: 5680100\"",
                    "-H", "\"app-template: 2\"",
                    "-H", "\"X-Platform: 71\"",
                    "-H", "\"app-platform: 1\"",
                    "-H", "\"mtgsig: {\\\"a1\\\":\\\"1.2\\\",\\\"a2\\\":1727232331928,\\\"a3\\\":\\\"1727231947469EQKIOMO60e593ce0a815b08d658526270cd17d63208\\\",\\\"a4\\\":\\\"3558b4cbedb3c450cbb4583550c4b3ed5364491203a0faff\\\",\\\"a5\\\":\\\"z4Snze8oQQLdr4sG8KwQqq+MjTi0PMjBzFhsGGP1nNuWRqRPoW0ZtjoQ8muD1l2HvnTJ5ifSKGDsly1N3Q7vj2eFitFJETGa/f+K8ywh0OOHYuCEK8wprzTUwm7YFw4XHBL8FF2HWRMF4x+FKa+Ooo3L3iSiNf3yOK4onZ6104RbhFde8aoRMNgsxHlFz4/oxJ9c9jqM4JfTNyf5qlYdUbuhgijdYR4MQWkXbyuwZur=\\\",\\\"a6\\\":\\\"w1.3EqOwHmHvAcSMT9+MNdYLz3dbaM38wuOadsiYqqsHGChwzdDmw27a2F7hRxItbzn2Js/UId41IMeNqFOb7EKWIdFJfTLJLha56sVQXnlRxhax6leVWRDQVlKwBPnMI/Nh+EQbvTdawiPpl9YjrC1f3a8KVXL9wTJgXBDaIKkLqqjVNwMEkE5aoT4ebpG4a5VJICZ0wcsZSawY7rwrOKa7JJCx/uKJvqa/WZa+SIUEIFTTVZASi/vvhvyxKCWN4QHnL+8+pSlPCW/OZz1vOAP8A5+LF7kh2qWtMe1KTENx7Ck6rGkzgXKsHNPM8O8IJDgIFqYEsHIOVujiyW2g1aH/2CJnRiDJA9iDf8Pkk9OJQNf5FjJtdrAyV8Sl3iOV2fEr02c1euQhQGDTnXZsuvBoIfRxgsI2RbcET959ckHAd5wk2d3MjsZAiIEiMYsjaBJG9v7XamtD/VghzFLcVboiQadIbTEjcY0GRS9u6r9Akn4KvXxHEsy7m0zePY5nbyj9\\\",\\\"a7\\\":\\\"wx177c513cc05c325d\\\",\\\"x0\\\":3,\\\"d1\\\":\\\"dfda079f4ea109520bb0ce016045263d\\\"}\"",
                    "-H", "\"X-user: 11STi122bPAM8aBTFd.kSiylh8F4cock2WAHmuI\"",
                    "-H", "\"lxcuid: 192270bf1afc8-18ea950f205de6-0-0-192270bf1afc8\"",
                    "-H", "\"X-appId: wx177c513cc05c325d\"",
                    "-H", "\"app-id: wx177c513cc05c325d\"",
                    "-H", "\"M-APPKEY: wxmp_com.sankuai.rmsmenuorderfe.v2.wxapp\"",
                    "-H", "\"promotion-monitoring: \"",
                    "-H", "\"appCode: 51\"",
                    "-H", "\"x-cardId: 2708581281\"",
                    "-H", "\"M-TRACEID: -701746510178537090\"",
                    "-H", "\"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b19)XWEB/11275\"",
                    "-H", "\"tenantId: 10159618\"",
                    "-H", "\"X-UnionId: oK9Wb524dtfZ9vTnIAB2bDzpVe3c\"",
                    "-H", "\"Content-Type: application/json\"",
                    "-H", "\"X-WxappVersion: 5.68.01\"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"app-container: 1\"",
                    "-H", "\"X-From: \"",
                    "-H", "\"X-OpenId: o6E8v44VuIG4RtAjGllbpAGICg0Y\"",
                    "-H", "\"X-cardInfo: \"",
                    "-H", "\"X-UserInfo: %7B%22nickname%22%3A%22%22%2C%22headimgurl%22%3A%22%22%7D\"",
                    "-H", "\"app-version: 5.68.01\"",
                    "-H", "\"Accept: */*\"",
                    "-H", "\"Sec-Fetch-Site: cross-site\"",
                    "-H", "\"Sec-Fetch-Mode: cors\"",
                    "-H", "\"Sec-Fetch-Dest: empty\"",
                    "-H", "\"Referer: https://servicewechat.com/wx177c513cc05c325d/203/page-frame.html\"",
                    "-H", "\"Accept-Language: zh-CN,zh;q=0.9\"",
                    "--data-binary", "\"{\\\"jumpType\\\":0,\\\"partnerType\\\":0,\\\"conditionType\\\":0,\\\"conditionValue\\\":\\\"\\\",\\\"latitude\\\":30.499839782714844,\\\"longitude\\\":114.342529296875,\\\"tenantId\\\":\\\"10159618\\\",\\\"bizType\\\":\\\"100\\\",\\\"cityId\\\":" + param[0].toString() + "}\"",
                    "--compressed", "\"https://rms.meituan.com/diancan/api/zt/shop/fmp?mtShopId=&yodaReady=wx&csecappid=wx177c513cc05c325d&csecplatform=3&csecversionname=72.59.000&csecversion=1.4.0\""
            };
            return String.join(" ", cmds);
        }
    },

    ChaHuaNong {
        @Override
        public void startSpider(int page, String cityId, StringBuilder stringBuilder) {
            String crulCmd = getCrulCmd(cityId);
            System.out.println(String.format("===> 获取数据茶话弄 %s 城市数据", cityId));

            String resultString = SpiderHelper.execCmd(crulCmd);
            TaNingResult taNingResult = JSON.parseObject(resultString, TaNingResult.class);

            TaNingData data = taNingResult.getData();
            if (data == null) {
                return;
            }

            Map<String, Object> moduleData = data.getModuleData();
            if (moduleData == null || moduleData.size() == 0) {
                return;
            }

            Object shopListObj = moduleData.get("shop-list");
            if (shopListObj == null) {
                return;
            }

            TaNingModuleShopListData taNingModuleShopListData = JSON.parseObject(JSON.toJSONString(shopListObj), TaNingModuleShopListData.class);
            if (taNingModuleShopListData == null) {
                return;
            }

            TaNingShopListData taNingShopListData = taNingModuleShopListData.getData();
            if (taNingShopListData == null) {
                return;
            }

            List<TaNingShopData> shopCardList = taNingShopListData.getShopCardList();
            for (TaNingShopData taNingShopData : shopCardList) {
                String phone = taNingShopData.getPhone();
                if (phone == null || phone.equals("")) {
                    continue;
                }

                stringBuilder.append(taNingShopData.getAddress()).append(" ").append(taNingShopData.getName()).append(", ").append(phone).append("\n");
            }
        }

        @Override
        public String getCrulCmd(Object... param) {
            String[] cmds = {
                    "curl",
                    "-H", "\"Host: rms.meituan.com\"",
                    "-H",
                    "\"X-cacheKey: \"",
                    "-H", "\"poiId: \"",
                    "-H", "\"X-token: UNI-TOKEN-11155978:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjcyNDA3NzEsImp0aSI6IjQ4MTBmYzg2ZmFmODQxZDJiNDU3MzQ2OTNmOGRjMDk3IiwibWVtYmVySWQiOjI5MzQ2NDEzMjF9.ZSb8N_8J5WGtMkibXsVt94PbC8ZoDySLgJPX99f0vWs;\"",
                    "-H", "\"versionCode: 5710500\"",
                    "-H", "\"app-template: 2\"",
                    "-H", "\"X-Platform: 71\"",
                    "-H", "\"app-platform: 1\"",
                    "-H", "\"mtgsig: {\\\"a1\\\":\\\"1.2\\\",\\\"a2\\\":1727233589866,\\\"a3\\\":\\\"1727233229478EISCKIG60e593ce0a815b08d658526270cd17d62403\\\",\\\"a4\\\":\\\"9ed5a58fa80671b38fa5d59eb37106a8e5a7f0b956d6f611\\\",\\\"a5\\\":\\\"9scjudvFC7cdQcQxAeWNSFfdVhPUPruVc5i76kRptGoOkStP0yhd4stvdbbZ8Et1QnSj9WCpiAm2oitm2jCxund18GM3ili0XJ0HUKK+zTn5D7RqQFalHtjMXzTmZZk8DgmPj5Oaz9ACobKZurPwkp1ZF5WSmuKhPNOZryA77xZDYV2wN9cHCBwcpahJnuuvLiPJ13xUpjzgy2s0+nrW73gdNKmB0+9HMOjGCybaTjr=\\\",\\\"a6\\\":\\\"w1.3S32s7fWSGk3F6G+zYgFFztdS2kiMox/AylC4iA6z+sPVJ83Eri1/LRddyV6gRsD8VAEhNJ/lvGMh9lHqSGicA6N59SzxpJyP3qABVaXDbt1qeQiBAe5U4avVZ0wAiFHhnBcUSf9HTudmYhtvGpiaikDEhnil3w6M7Di+KvCh+gAPB+Fx6w1d4n7qHtXlu84t71Suyrzim8grqIGyOftRHgWb8hV/6V4DqKPGzyGW1e2r72EsHxEiS5luNcHKcRK55Xzm48w1wDwwodiiiSUDxa1Nm89Epg123B9Aq/u8jkwlhHQfwkrTcEnUqsOpmVm9j/SUIjHsYAG5iHWBHNLvhRlnsS1ufXK8Iis+kOCNu85aVaQqd2gHgp39wz9ySjxuwErhraa0JamRs1dtiG4m3cb3A7uXUBvslGJZrIa8xDRBSemAeB4Oo6xTJIRomwDO5X9HC4Z3hpOGGFk4Tb9Rc2l7ceAHFvhip4GJWIFBXXL5vOwJ3VlKe+TV0Y6uRrkc\\\",\\\"a7\\\":\\\"wx1ca7564b0801efe2\\\",\\\"x0\\\":3,\\\"d1\\\":\\\"4ca85495f69af0033467b4adc43d3149\\\"}\"",
                    "-H", "\"X-user: 11STilI2bPCiLM09Cg.Sc21AMdrqzl-x4H-lfZm\"",
                    "-H", "\"lxcuid: 192271f8192c8-44b301eacae1c0-0-0-192271f8192c8\"",
                    "-H", "\"X-appId: wx1ca7564b0801efe2\"",
                    "-H", "\"app-id: wx1ca7564b0801efe2\"",
                    "-H", "\"M-APPKEY: wxmp_com.sankuai.rmsmenuorderfe.v2.wxapp\"",
                    "-H", "\"promotion-monitoring: \"",
                    "-H", "\"appCode: 51\"",
                    "-H", "\"x-cardId: 2707276196\"",
                    "-H", "\"M-TRACEID: -3723890187790187636\"",
                    "-H", "\"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090b19)XWEB/11275\"",
                    "-H", "\"tenantId: 11155978\"",
                    "-H", "\"X-UnionId: o3VsP68TWg7BmsVpdS1cs_CMoRC0\"",
                    "-H", "\"Content-Type: application/json\"",
                    "-H", "\"X-WxappVersion: 5.71.05\"",
                    "-H", "\"xweb_xhr: 1\"",
                    "-H", "\"app-container: 1\"",
                    "-H", "\"X-From: \"",
                    "-H", "\"X-OpenId: of62W5TIs9zNwn_nTjPXjl_kXoTU\"",
                    "-H", "\"X-cardInfo: \"",
                    "-H", "\"X-UserInfo: %7B%22nickname%22%3A%22%22%2C%22headimgurl%22%3A%22%22%7D\"",
                    "-H", "\"app-version: 5.71.05\"",
                    "-H", "\"Accept: */*\"",
                    "-H", "\"Sec-Fetch-Site: cross-site\"",
                    "-H", "\"Sec-Fetch-Mode: cors\"",
                    "-H", "\"Sec-Fetch-Dest: empty\"",
                    "-H", "\"Referer: https://servicewechat.com/wx1ca7564b0801efe2/123/page-frame.html\"",
                    "-H", "\"Accept-Language: zh-CN,zh;q=0.9\"",
                    "--data-binary", "\"{\\\"jumpType\\\":0,\\\"partnerType\\\":0,\\\"conditionType\\\":0,\\\"conditionValue\\\":\\\"\\\",\\\"latitude\\\":30.499839782714844,\\\"longitude\\\":114.342529296875,\\\"tenantId\\\":\\\"11155978\\\",\\\"bizType\\\":\\\"100\\\",\\\"cityId\\\":" + param[0].toString() + "}\"",
                    "--compressed", "\"https://rms.meituan.com/diancan/api/zt/shop/fmp?mtShopId=&yodaReady=wx&csecappid=wx1ca7564b0801efe2&csecplatform=3&csecversionname=75.48.000&csecversion=1.4.0\""
            };
            return String.join(" ", cmds);
        }
    };

    protected String getData(Object[] param) {
        return "";
    }

    public abstract String getCrulCmd(Object... param);


    public abstract void startSpider(int page, String cityId, StringBuilder stringBuilder);
}
